package vn.allmobile.ambnews.fragment;

import java.util.List;

import vn.allmobile.ambnews.R;
import vn.allmobile.ambnews.data.Paper;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class SortListViewAdapter extends BaseAdapter {
	List<Paper> mList;

	public SortListViewAdapter(Context context, List<Paper> list) {
		this.mList = list;
	}

	public List<Paper> getList() {
		return mList;
	}

	public void setmList(List<Paper> mList) {
		this.mList = mList;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return this.mList.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return this.mList.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			convertView = parent.inflate(parent.getContext(),
					R.layout.allpapers_list_item_handle_right, null);
		}
		TextView mTextView = (TextView) convertView.findViewById(R.id.text);
		mTextView.setText(this.mList.get(position).getTitle());
		return convertView;
	}

	public void remove(Paper paper) {
		this.mList.remove(paper);
	}

	public void insert(Paper paper, int to) {
		this.mList.add(to, paper);
	}

}
